{template common/contentheader} 
<div class="setcontent">
	<div class="settitle">
		<h3>{lang edit_category:admin}-$category['category_name_cn']</h3>
	</div>
	<div class="alert alert-info mt10">
		<span class="label label-info">{lang info:admin}</span>
		{lang admin_content_category_tip:admin}
	</div>
	<div class="setform">
		<form class="pzform" method="post" action="{url admin/contentcategory?act=edit&catid=$category['category_id']}" id="addform">
			
			<div class="formgroup">
				<label class="formlabel">{lang parent_category:admin}:</label>
				<div class="formcontrol">
					<div class="input-prepend" id="popcategory" style="margin-left: 2px;">
						<input id="parent_id" name="parent_id" type="hidden" class="select_id" value="$category['parent_id']">
						<input id="parent_name" name="parent_name" type="hidden" class="select_title" value="$category['parent_name']">
						<a href="javascript:void(0);" class="btn category-popbutton"><span class="select_title">{if $category['parent_name']}$category['parent_name']{else}{lang tip_plsselect}{/if}</span> <span class="caret ml10"></span></a>
					</div>
				</div>
				<span class="formhelp">{lang parent_category_tip:admin}</span>
			</div>
			
			<div class="formgroup">
				<label class="formlabel">{lang category_name_cn:admin}:</label>
				<div class="formcontrol">
					<input type="text" name="category_name_cn" value="$category['category_name_cn']" id="category_name_cn"/>
				</div>
				<span class="formhelp">{lang category_name_cn_tip:admin}</span>
			</div>
			
			<div class="formgroup">
				<label class="formlabel">{lang category_name_en:admin}:</label>
				<div class="formcontrol">
					<input type="text" name="category_name_en" value="$category['category_name_en']" id="category_name_en"/>
				</div>
				<span class="formhelp">{lang category_name_en_tip:admin}</span>
			</div>
			
			<div class="formgroup">
				<label class="formlabel">{lang th_displayorder:admin}:</label>
				<div class="formcontrol">
					<input type="text" name="display_order" value="$category['display_order']" id="display_order"/>
				</div>
				<span class="formhelp">{lang th_displayorder:admin}</span>
			</div>
			
			<div class="formgroup">
				<label class="formlabel">{lang category_is_open:admin}:</label>
				<div class="formcontrol">
					<input type="radio" name="is_open" value="1" {if $category['is_open']}checked{/if}>{lang yes:admin}</input>
              		<input type="radio" name="is_open" value="0" {if !$category['is_open']}checked{/if}>{lang no:admin}</input>
				</div>
				<span class="formhelp">{lang category_is_open_tip:admin}</span>
			</div> 
			
			
			<div class="formgroup">
				<label class="formlabel">{lang category_is_home:admin}:</label>
				<div class="formcontrol">
					<input type="radio" name="is_home" value="1" {if $category['is_home']}checked{/if}>{lang yes:admin}</input>
              		<input type="radio" name="is_home" value="0" {if !$category['is_home']}checked{/if}>{lang no:admin}</input>
				</div>
				<span class="formhelp">{lang category_is_home_tip:admin}</span>
			</div> 
			<div class="formgroup">
				<label class="formlabel">{lang category_hot_words:admin}:</label>
				<div class="formcontrol">
					<textarea id="category_hot_words" name="category_hot_words" rows="3">$category['category_hot_words']</textarea>
				</div>
				<span class="formhelp">{lang category_hot_words_tip:admin}</span>
			</div>
			
			<div class="formgroup">
				<label class="formlabel">{lang cover}:</label>
				<div class="formcontrol">
					<img alt="" src="{baseurl}data/attachments/category/{$category['category_id']}_cat.jpg">
              		<div id="button1" class="btn">{lang upload_pic:admin}</div>
              		<input type="hidden" class="input-text" name="filename" id="filename"/>
				</div>
				<span class="formhelp">{lang category_cover_tip:admin}</span> 
			</div>
			<div class="formbuttons">
				<button type="submit" class="btn btn-primary">{lang save:admin}</button>
			</div>
		</form>
	</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
	$('#parent_id').change(function (){
		$("#parent_name").val($('#parent_id option:selected').attr('data-name'));
	});
	$('.category-popbutton').popcategory({
		top: '182px',
		left: '20px',
		targetid: 'popcategory',
		showRoot: true,
		tpl: 'deepcategory'});
	var button = $('#button1'), interval;
	new AjaxUpload(button, {
		action: '{url admin/contentcategory?act=upload&catid=$category['category_id']}', 
		name: 'qqfile',
		responseType: 'json',
		onSubmit : function(file, ext){
			button.text('Uploading');
			this.disable();
			interval = window.setInterval(function(){
				var text = button.text();
				if (text.length < 13){
					button.text(text + '.');					
				} else {
					button.text('Uploading');				
				}
			}, 200);
		},
		onComplete: function(file, result){
			button.text('{lang upload_pic:admin}');
			window.clearInterval(interval);
						
			// enable upload button
			this.enable();
			if(result.success === 0){
				alert(result.message);
				return;
			}
			window.location.reload();
		}
	});
});
</script>
{template common/contentfooter}